<template>
    <vue-table :data-source="tableList">
        <template slot="header">
            <tr>
                <th>公众号名称</th>
                <th>发送类型</th>
                <th>审批状态</th>
                <th>添加时间</th>
                <th>操作</th>
            </tr>
        </template>
        <template slot="tbody" slot-scope="props">
            <tr>
                <td>{{props.item.wechats.nick_name}}</td>
                <td>{{$store.state.replyTypeList[props.item.type]}}</td>
                <td>{{type[props.item.check_status]}}</td>
                <td>{{props.item.created_at}}</td>
                <td class="col-lg-2" v-if="props.item.status == 1">

                    <button title="查看" class="btn btn-white btn-xs m-b-none"
                    v-on:click="showDialog(props.item.id)">
                        <i class="fa fa-eye"></i> 查看
                    </button>
                </td>
                <td class="col-lg-2" v-if="props.item.status == 0">

                    <button title="审批" class="btn btn-white btn-xs m-b-none"
                            v-on:click="showDialog(props.item.id)">
                        <i class="fa fa-eye"></i> 审批
                    </button>
                </td>
            </tr>
        </template>
    </vue-table>
</template>

<script>
    export default {
        props: {
            stateManager: {
                type: Object
            }
        },
        data: function () {
            return {
                type:{"1":"待审批","2":"审批通过","3":"审批驳回"},
                list: this.$listDataSource({
                    url:'/api/WeChat/MassLog',
                }),
//                ReturnArr: {'0': '未回复', '1': '已回复'},
            };
        },
        methods: {
            showDialog: function (uuid) {
                this.stateManager.SeeDialogVisible = true;
                this.stateManager.SeeModelId = uuid;
            },
            changeTime:function (time) {
                return new Date(parseInt(time) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
            },
            showDeleteDialog: function (uuid) {
                this.stateManager.deleteDialogVisible = true;
                this.stateManager.deleteModelId = uuid;
            }
        },
        computed: {
            user(){
                return this.$store.state.user;
            },
            tableList(){
                if (this.stateManager.refreshList) {
                    this.list.fetch();
                    this.stateManager.refreshList = false;
                }
                return this.list;
            }
        }
    }
</script>